<template>
  <el-form class="add-event-link">
    <slider-normal v-if="isAutoLink" v-model="linkEvent.comps[3].attrs.delayTime" :min="0" :max="10" :step="1" label="自动关闭时间(s)" @change="onUpdateEvent"></slider-normal>
  </el-form>
</template>

<script setup lang="ts">
import { useWebControlsStore } from '@/store/web/controls'
import { useWebComponentStore } from '@/store/web/component'
import { GENERAL_TYPES } from '@/const/'
import { getWbListByItem } from '@/components/utils'

const props = defineProps<{ 
  event: IEvent,
  index: number,
}>()

const event = props.event
const useWebControls = useWebControlsStore()
const useWebComponent = useWebComponentStore()
const linkEvent = computed(() => {
  return useWebComponent.currentComponentData!.events.link
})
const isAutoLink = computed(() => {
  const event: IEvent = useWebComponent.currentComponentData!.events.link
  if(event) {
    return event.comps[3] && event.comps[3].attrs.value
  } else {
    return false
  }
})
const onUpdateEvent = () => {
  const event: IEvent = useWebComponent.currentComponentData!.events.link
  useWebComponent.updateEvent({ type: event.type, event })
}
</script>